package com.credithc.customers.dataservice.mapper.GD;

import com.credithc.baseserv.core.mapper.BsBaseMapper;
import com.credithc.customers.dataservice.po.CrmIntopiecesDkPO;
import com.credithc.customers.dataservice.po.GdCustomerProductPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CrmIntopiecesDkMapper extends BsBaseMapper<CrmIntopiecesDkPO> {
    @Select("select MAX(id)  from crm_intopieces_dk")
    Long queryProductMaxId();
    @Select("SELECT  crm_intopieces_dk.id tableKey,crm_intopieces_dk.loan_type loanType,crm_account_mes_dk.account_type accountSys, crm_account_mes_dk.is_trust Trust , \n" +
            "            crm_account_mes_dk.is_new_platform newPlatform,crm_intopieces_dk.state state,crm_repay_dk.status status ,crm_intopieces_dk.pieces_type intopiecesSys ,crm_intopieces_dk.count intopiecesAmount  ,\n" +
            "            crm_account_mes_dk.loan_qishu carMonth ,crm_account_mes_dk.repay_end_time productEndTime ,crm_account_mes_dk.reg_qixi_day productStartTime ,\n" +
            "            crm_account_mes_dk.account_money accountAmount ,crm_intopieces_info_dk.client_id preCustomerNo ,crm_intopieces_info_dk.knnent_id customerNo \n" +
            "            from crm_intopieces_dk \n" +
            "            LEFT JOIN crm_account_mes_dk on  crm_intopieces_dk.id = crm_account_mes_dk.intopieces_id\n" +
            "            LEFT JOIN crm_repay_dk on crm_account_mes_dk.id = crm_repay_dk.contract_id\n" +
            "            LEFT JOIN crm_intopieces_info_dk on crm_intopieces_dk.id = crm_intopieces_info_dk.ip_id \n" +
            "            where crm_intopieces_dk.id< #{id} and crm_intopieces_dk.id >= #{id}-1000  ORDER BY crm_intopieces_dk.id desc;")
    List<GdCustomerProductPO> queryDlrProduct(String id);
    @Select("SELECT  crm_intopieces_dk.id tableKey,crm_intopieces_dk.loan_type loanType,crm_account_mes_dk.account_type accountSys, crm_account_mes_dk.is_trust Trust , \n" +
            "            crm_account_mes_dk.is_new_platform newPlatform,crm_intopieces_dk.state state ,crm_repay_dk.status status ,crm_intopieces_dk.pieces_type intopiecesSys ,crm_intopieces_dk.count intopiecesAmount  ,\n" +
            "            crm_account_mes_dk.loan_qishu carMonth ,crm_account_mes_dk.repay_end_time productEndTime ,crm_account_mes_dk.reg_qixi_day productStartTime ,\n" +
            "            crm_account_mes_dk.account_money accountAmount ,crm_intopieces_info_dk.client_id preCustomerNo ,crm_intopieces_info_dk.knnent_id customerNo \n" +
            "            from crm_intopieces_dk \n" +
            "            LEFT JOIN crm_account_mes_dk on  crm_intopieces_dk.id = crm_account_mes_dk.intopieces_id\n" +
            "            LEFT JOIN crm_repay_dk on crm_account_mes_dk.id = crm_repay_dk.contract_id\n" +
            "            LEFT JOIN crm_intopieces_info_dk on crm_intopieces_dk.id = crm_intopieces_info_dk.ip_id \n" +
            "            ORDER BY crm_intopieces_dk.id desc ")
    List<GdCustomerProductPO> queryGDProduct( @Param("rowBounds") RowBounds rowBounds);
}
